import { applyMiddleware, createStore } from "redux";
import reducer from "./reducer"
import logger from 'redux-logger'
// 导入持久化插件
import { persistStore, persistReducer } from "redux-persist"
import storage from "redux-persist/lib/storage";
import thunk from "redux-thunk"
// 生成一个持久化的reducer、
var persistedReducer = persistReducer({ key: 'redux', storage }, reducer)

// 创建store
var store = createStore(persistedReducer, applyMiddleware(thunk, logger))

// 生成一个持久化的store
export var persistor = persistStore(store);
export default store;